#include "mcolor.h"
#ifdef GUI_APPLICATION

void MColor::set(muint8 red, muint8 green, muint8 blue)
{
	_red = red;
	_green = green;
	_blue = blue;
}

void MColor::flip()
{
	_red = 255 - _red;
	_green = 255 - _green;
	_blue = 255 - _blue;
}

MColor MColor::Opposite() const
{
	return MColor(255-_red, 255-_green, 255-_blue);
}

MColor MColor::Opposite(const MColor &color)
{
	return MColor(255-color._red, 255-color._green, 255-color._blue);
}

muint32 MColor::brightness() const
{
	return ((_red*3UL + _blue + (_green<<2UL)) >> 3UL) /
		(255UL*3 + 255UL + (255UL<<2)) >> 3UL;
}

muint32 MColor::brightness(const MColor &color)
{
	return ((color._red*3UL + color._blue + (color._green<<2UL)) >> 3UL) /
		(255UL*3 + 255UL + (255UL<<2)) >> 3UL;
}

const MColor &MColor::operator=(const MColor &other)
{
	_red = other._red;
	_green = other._green;
	_blue = other._blue;
	return *this;
}


#endif //GUI_APPLICATION
